package com.tcd.outRisk.controller;


import com.tcd.outRisk.entity.DispatchedWorkerInfo;
import com.tcd.outRisk.service.ClaimMainInfoService;
import com.tcd.outRisk.service.DispatchedWorkerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 调度派工信息表 前端控制器
 * </p>
 *
 * @author Jarle
 * @since 2021-05-22
 */
@CrossOrigin
@RestController
@RequestMapping("/Dispatchedinfo")
public class DispatchedWorkerInfoController {
    @Autowired
    ClaimMainInfoService claim;
    @Autowired
    DispatchedWorkerInfoService dispatched;

    @RequestMapping("/Dispatchadd")
    public boolean DispatchedWorderAdd(Integer dispatchid, Long[] num) {
        boolean flag = false;
        List<DispatchedWorkerInfo> dispatchlist = new ArrayList<>();//派工集合
        if (dispatched.DCount(dispatchid + "") > 0) {
            return flag;
        }
        //用户ID:dispatchid
        for (Long i : num) {
            dispatchlist.add(new DispatchedWorkerInfo(0, i, dispatchid, new Date(System.currentTimeMillis()), 1));
        }
        flag = dispatched.saveBatch(dispatchlist);
        return flag;
    }

    @RequestMapping("/Dispatchlist")
    public List<DispatchedWorkerInfo> dlist() {
        return dispatched.list();
    }

    @RequestMapping("/DispatchEditstatus")
    public boolean DeditStatus(String clainMainid, String status) {
        return dispatched.DeditStatus(clainMainid, status);
    }
}

